import java.util.Scanner;

public class Zhishu {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.nextLine());
        int value[] = new int[k];
        for (int i = 0; i < k; i++) {
            value[i]=Integer.parseInt(sc.nextLine());
        }
        value = getAllValue(k,value);
        for (int i = 0; i < value.length; i++) {
            System.out.println(value[i]);
        }
    }

    private static int[] getAllValue(int k, int[] value) {
        int result [] = new int[k];
        for (int i = 0; i < value.length; i++) {
            char[] chars = (value[i] + "").toCharArray();
            boolean zhishu = isZhi(value[i]);
            int count = 0;
            if(zhishu) result[i] = 1;
            else {
                for (int j = 0; j < chars.length; j++) {
                }
            }
        }
        return null;
    }

    private static boolean isZhi(int i) {
        for (int j = 2; j < i; j++) {
            if(i%j == 0) return false;
        }
        return true;
    }
}
